using Coding4Fun.Phone.Controls;
using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Protocol;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.Page
{
	public class GetPasswordByPhoneView : BasePage
	{
		private const string TAG = "GetPasswordByPhoneView";
		private EventWatcher mWatcherResetPassByPhone;
		internal Grid LayoutRoot;
		internal Grid sencondRoot;
		internal panelTitle2Line panelTitle;
		internal StackPanel ContentPanel;
		internal InputPhoneNumCtrl mPhoneNumInputer;
		internal TextBlock textBlock1;
		private bool _contentLoaded;
		public GetPasswordByPhoneView()
		{
			this.InitializeComponent();
			this.SetAppBarWording();
		}
		protected override void OnPageIn(object[] object_0)
		{
			if (this.mWatcherResetPassByPhone == null)
			{
				this.mWatcherResetPassByPhone = new EventWatcher(this, null, new EventHandlerDelegate(this.onMobileResetPwdHandler));
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_RESETPWD_SUCCESS, this.mWatcherResetPassByPhone);
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_RESETPWD_ERR, this.mWatcherResetPassByPhone);
			}
		}
		protected override void OnPageOut()
		{
			if (this.mWatcherResetPassByPhone != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_RESETPWD_SUCCESS, this.mWatcherResetPassByPhone);
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_RESETPWD_ERR, this.mWatcherResetPassByPhone);
				this.mWatcherResetPassByPhone = null;
			}
		}
		public void inputDone(object sender, object object_0)
		{
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(true);
		}
		public void inputNotDone(object sender, object object_0)
		{
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(false);
		}
		private void btnPreviousStep_Click(object sender, EventArgs e)
		{
			base.GoBack();
		}
		private void btnNextStep_Click(object sender, EventArgs e)
		{
			this.disableAllControls();
			ServiceCenter.sceneResetPwd.doScene(this.mPhoneNumInputer.GetPhoneNumber());
		}
		private void enableAllControls()
		{
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(true);
		}
		private void disableAllControls()
		{
			ProcessingCover.getProgressBar(this.LayoutRoot, null, null, false, false, null);
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(false);
		}
		private void onMobileResetPwdHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.enableAllControls();
			if (EventConst.ON_NETSCENE_RESETPWD_SUCCESS == evtArgs.mEventID)
			{
				(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(false);
				ToastPrompt toastPrompt = MessageBoxManager.ShowToast(strings.Login_GetPassByP_MsgSucc, 2500, null, false);
				toastPrompt.Completed += new EventHandler<PopUpEventArgs<string, PopUpResult>>(this.tToast_Completed);
				return;
			}
			if (EventConst.ON_NETSCENE_RESETPWD_ERR == evtArgs.mEventID)
			{
				RetConst retConst = RetConst.MM_OK;
				if (evtArgs.mObject != null)
				{
					retConst = (RetConst)evtArgs.mObject;
					Log.smethod_5("GetPasswordByPhoneView", "onMobileResetPwdHandler:evtArgs.mObject is" + retConst);
				}
				else
				{
					Log.smethod_5("GetPasswordByPhoneView", "onMobileResetPwdHandler:evtArgs.mObject is null");
				}
				RetConst retConst2 = retConst;
				if (retConst2 == RetConst.MM_ERR_CLIENT)
				{
					MMMessageBox.Show(strings.Login_GetPassByP_MsgBadNet, true, "确定");
					return;
				}
				if (retConst2 == RetConst.MM_ERR_MOBILE_FORMAT)
				{
					MMMessageBox.Show(strings.Reg_PhoneNum_MsgBadNum, true, "确定");
					return;
				}
				switch (retConst2)
				{
				case RetConst.MM_ERR_MOBILE_UNBINDED:
					MMMessageBox.Show(strings.Login_GetPassByP_MsgBadNum, true, "确定");
					return;
				case RetConst.MM_ERR_FREQ_LIMITED:
					MMMessageBox.Show(strings.Login_GetPassByP_MsgTooFreq, true, "确定");
					return;
				}
				MMMessageBox.Show(strings.Login_GetPassByP_MsgBadNum, true, "确定");
			}
		}
		private void tToast_Completed(object sender, PopUpEventArgs<string, PopUpResult> e)
		{
			PhoneApplicationFrame phoneApplicationFrame = Application.get_Current().get_RootVisual() as PhoneApplicationFrame;
			BasePage basePage = phoneApplicationFrame.get_Content() as BasePage;
			if (basePage == this)
			{
				PageManager.getInstance().PopPage();
				base.GoBack();
			}
		}
		public void SetAppBarWording()
		{
			if (base.get_ApplicationBar() != null && 1 == base.get_ApplicationBar().get_Buttons().get_Count())
			{
				ApplicationBarIconButton applicationBarIconButton = (ApplicationBarIconButton)base.get_ApplicationBar().get_Buttons().get_Item(0);
				applicationBarIconButton.set_Text(strings.COM_Next);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/LoginViews/GetPasswordByPhoneView.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.sencondRoot = (Grid)base.FindName("sencondRoot");
			this.panelTitle = (panelTitle2Line)base.FindName("panelTitle");
			this.ContentPanel = (StackPanel)base.FindName("ContentPanel");
			this.mPhoneNumInputer = (InputPhoneNumCtrl)base.FindName("mPhoneNumInputer");
			this.textBlock1 = (TextBlock)base.FindName("textBlock1");
		}
	}
}
